<template>
  <div class="aaa"></div>
</template>

<script setup>
  import { ref, onMounted } from 'vue'
  import DynamicWallMaterialProperty from '@/utils/electronic.js'
  import Heatmap from '@/utils/heatmap.js'

  let viewer = null;

  const initPage = () => {
    // // 初始化场景位置
    // viewer.scene.camera.setView({
    //   // 初始化相机经纬度
    //   destination: new Cesium.Cartesian3.fromDegrees(119.2, 34.6, 500),
    //   orientation: {
    //     heading: Cesium.Math.toRadians(0),
    //     pitch: Cesium.Math.toRadians(-90),
    //     roll: Cesium.Math.toRadians(0)
    //   }
    // });

    // 电子围栏
    const ett = viewer.entities.add({
      name: "动态立体墙",
      wall: {
        positions: Cesium.Cartesian3.fromDegreesArray([117.154815, 31.853495, 117.181255, 31.854257, 117.182284, 31.848255, 117.184748, 31.840141, 117.180557, 31.835556, 117.180023, 31.833741, 117.166846, 31.833737, 117.155531, 31.833151, 117.154787, 31.835978, 117.151994, 31.839036, 117.150691, 31.8416, 117.151215, 31.844734, 117.154457, 31.848152, 117.154815, 31.853495]),
        maximumHeights: [600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600],
        minimumHeights: [43.9, 49.4, 38.7, 40, 54, 51, 66.7, 44.6, 41.2, 31.2, 50.1, 53.8, 46.9, 43.9],
        material: new DynamicWallMaterialProperty('/Cesium/blueenclosure.png', Cesium.Color.ORANGE, 2000)
      }
    });
    
    // viewer.flyTo(ett);

    // 热力图
    let list = [];
    for (let i = 0; i < 100; i++) {
      list.push({
        "lnglat": [
          117.28 + Math.random() * (Math.random() > 0.05 ? .1 : -.1),
          31.923 + Math.random() * (Math.random() > 0.05 ? .1 : -.1)
        ],
        "value": 50 * Math.random() + 50
      })
    }
    new Heatmap(viewer, {
        list: list,
        radio: 10,
        blur: 1,
        gradient: {
          '.2': 'blue',
          '.4': 'pink',
          '.6': 'yellow',
          '.7': 'red',
          '.8': 'FIREBRICK',
          '.9': 'INDIGO',
        }
    })
  }

  onMounted(() => {
    viewer = window?.cesiumViewer
    initPage()
  })
</script>

<style scoped lang='scss'>
  
</style>
